<?php

/**
 * @author edson
 * @copyright 2011
 */

class CDrawMenuTour
{
    public static $instance;
     function __construct()
    {
        
        
    }
    /*************************************************************************************************/
    /*
  @brief esta funcion dibuja un conjunto de items dentro de un menu 

  @param subdevice target subdevice, an integer between 0 and 255
  @param line line to be modifided, in general, a value between 0 and 31, but depends on the target slave
  @param value state to be written to thew line, mus be 0 or 1

  @returns the result of the operation, being cd_Error_NoError if all worked OK

  Example:
  \verbatim
      cd_Error my_error;

      my_error = cdm_DAQWriteDigitalLine(2,31,1);
      if (my_error != CD_Erro_NoError) {
            printf("Ups, this failed with error %s\n", cd_ErrorStr(my_error);
      }
   \endverbatim

  */
  
  function DrawDivAdBegin(){$tab=func_get_args();if(count(func_get_args())>1){echo "<div id=\"$tab[0]\">";return;} echo "<div class=\"$tab[0]\">";}
    function DrawDivAdEnd(){echo "</div>"; }
    
    function setMenu()
    {
       
    
//------------------menu-----------------------------
?>
    <div id="two_column_left_sidebar">  <!--empieza two_column_left_sidebar-->
    <div id="owner_block">
    <div id="owner_block_submenu">
    <div class="submenu_group">
    <div class="submenu_group_a">
    <ul>
<?php
    
    
    if(func_num_args()!=0)//arreglo del tipo valor = link , id = nombre de item 
        {   
            $items=func_get_args();
            //var_dump($items);
            foreach($items as $i => $j)
            {
                foreach($j as $id => $valor)
                {
                echo "<li><a href='$valor'>$id </a></li>";
                }
            }
            
            
            
        
        }
        else{
        $data=explode(',',$_COOKIE['cookie_user']);
    //$prueba="select*from trabajadores WHERE UseTra='$data[0]' and PassTra='$data[1]'";
     $cadena="select * from trabajadores where UseTra='$data[0]' and PassTra='$data[1]'";
    $scheme=CModelo::getInstance()->getData($cadena);
    //var_dump($scheme);
    //$menus="select * from items where valTotMod MOD(select valPer from perfiles where IdPer=(select perfiles_idPer from trabajadores where UseTra='$data[0]'))";
    //$menus="select * from sidebar where ";
    $menus="select * from items where idIte=(select items_idIte from sidebar where modulos_idMod=(select modPri from perfiles where IdPer=(select perfiles_idPer from trabajadores where UseTra='$data[0]')))";
    echo $menus;
    
    $scheme=CModelo::getInstance()->getData($menus);
    //var_dump($scheme);
    //var_dump($scheme);
    //$t="select valPer from perfiles where IdPer=(select perfiles_idPer from trabajadores where UseTra='$data[0]')";
    //$t=CModelo::getInstance()->getData($t);
    //var_dump($t);
    foreach($scheme as $row =>$colum)
    {
        $tabla=$colum;
         echo "<li><a href='$tabla[Link]'>$tabla[nomIte] </a></li>";    
    }  
}
    ?>
    </ul>
    </div>
    </div>
    </div>
    </div>
    </div><!--acaba two_column_left_sidebar-->
<?php  
    }
    function rigth_side_begin()
    {
        ?>
        <div id="two_column_left_sidebar_maincontent">
         <?php
    }
    function rigth_side_end(){echo "</div>";}
    function setMenuDisplay()
    {
    ?>
        <div id="two_column_left_sidebar">  <!--empieza two_column_left_sidebar-->
    <div id="owner_block">
    <div id="owner_block_submenu">
    <div class="submenu_group">
    <div class="submenu_group_a">
    <ul>
    <?php
        $items=func_get_args();
            //var_dump($items);
            foreach($items as $i => $j)
            {
                foreach($j as $id => $valor){//$id identifica al nombre de ID k deseamos desplazar
                    ?>
                 <li><a href="#" onclick="$('#<?php echo $id;?>').toggle()"><?php echo $valor ;?></a></li>
                    <?php
            
            }
            }
        
        ?>
    </ul>
    </div>
    </div>
    </div>
    </div>
    </div><!--acaba two_column_left_sidebar-->
<?php  
        
    }
    
    public static function getInstance()
	{
		//echo "<div id=register-box>";
        if(self::$instance==null)
		  self::$instance=new CDrawMenuTour();
	//   echo "</div>";	  
		return  self::$instance;
	   
    
    }	
    
    
}

?>